package com.musichord.core.message;

import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MetaMessage;

import com.musichord.core.helper.MidiInfo;

public class MeterMessage extends MetaMessage {
	public MeterMessage(int numerator, int denominator) {
		super();
		int denominatorExponent = (int) (Math.log(denominator) / Math.log(2));
		//System.out.println(denominatorExponent);
		data = new byte[4];
		data[0] = (new Integer(numerator)).byteValue();
		data[1] = (new Integer(denominatorExponent)).byteValue();
		data[2] = (new Integer(24)).byteValue();
		data[3] = (new Integer(8)).byteValue();
		try {
			setMessage(MidiInfo.METER_CHANGE, data, data.length);
		} catch (InvalidMidiDataException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
